import Vue from 'vue'
//自定义filter
Vue.filter('dateFormatter', function(value, format) {
  if(!value) return ''
  if(!format) format = 'yyyy-MM-dd'
  let crtTime = new Date(value);
  let o = {
    "M+": crtTime.getMonth() + 1, //月份
    "d+": crtTime.getDate(), //日
    "h+": crtTime.getHours(), //小时
    "m+": crtTime.getMinutes(), //分
    "s+": crtTime.getSeconds(), //秒
    "q+": Math.floor((crtTime.getMonth() + 3) / 3), //季度
    "S": crtTime.getMilliseconds() //毫秒
  };
  if (/(y+)/.test(format))
    format = format.replace(RegExp.$1, (crtTime.getFullYear() + "").substr(4 - RegExp.$1.length));
  for (let k in o)
    if (new RegExp("(" + k + ")").test(format))
      format = format.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
  return format;
});

Vue.filter('deviceStatus', function(value) {
  let statusName = ''
  switch (value) {
    case '1':
      statusName = '正常使用'
      break
    case '2':
      statusName = '已退机'
      break
    case '3':
      statusName = '已停机'
      break
    default:
      statusName = ''
      break
    }
    return statusName
})

Vue.filter('processStatus', function(value) {
  let statusName = ''
  switch (value) {
    case 1:
      statusName = '待我处理'
      break
    case 2:
      statusName = '已完成'
      break
    case 3:
      statusName = '已取消'
      break
    case 4:
      statusName = '已拒绝'
      break
    default:
      statusName = '待我处理'
      break
    }
    return statusName
})
Vue.filter('handledProcessStatus', function(value) {
  let statusName = ''
  switch (value) {
    case 1:
      statusName = '进行中'
      break
    case 2:
      statusName = '已完成'
      break
    case 3:
      statusName = '已取消'
      break
    case 4:
      statusName = '已拒绝'
      break
    default:
      statusName = '进行中'
      break
    }
    return statusName
})

Vue.filter('processStatusClassName', function(value) {
  let statusName = ''
  switch (value) {
    case 1:
      statusName = 'processing'
      break
    case 2:
      statusName = 'finish'
      break
    case 3:
      statusName = 'cancel'
      break
    case 4:
      statusName = 'cancel'
      break
    default:
      statusName = 'processing'
      break
    }
    return statusName
})

Vue.filter('stepStatus', function(value) {
  let statusName = ''
  switch (value) {
    case -1:
      statusName = 'finish'
      break
    case 0:
      statusName = 'process'
      break
    case 1:
      statusName = 'success'
      break
    case 2:
      statusName = 'wait'
      break
    case 3:
      statusName = 'error'
      break
    case 4:
      statusName = 'error'
      break
    case 5:
      statusName = 'error'
      break
    case 6:
      statusName = 'success'
      break
    case 7:
      statusName = 'success'
      break
    default:
      statusName = 'wait'
      break
    }
    return statusName
})

Vue.filter('feedbackStepStatusName', function(value) {
  let statusName = ''
  switch (value) {
    case -1:
      statusName = '发起审批'
      break
    case 0:
      statusName = '审批中'
      break
    case 1:
      statusName = '已同意'
      break
    case 2:
      statusName = '待审批'
      break
    case 3:
      statusName = '已结束'
      break
    case 4:
      statusName = '已撤销'
      break
    case 5:
      statusName = '已拒绝'
      break
    case 6:
      statusName = '添加评论'
      break
    case 7:
      statusName = '已转交'
      break
    default:
      statusName = '待处理'
      break
    }
    return statusName
})
Vue.filter('calibrationStepStatusName', function(value) {
  let statusName = ''
  switch (value) {
    case -1:
      statusName = '校准任务发起'
      break
    case 0:
      statusName = '处理中'
      break
    case 1:
      statusName = '已完成'
      break
    case 2:
      statusName = '待处理'
      break
    case 3:
      statusName = '已结束'
      break
    case 4:
      statusName = '已撤销'
      break
    case 5:
      statusName = '已拒绝'
      break
    case 6:
      statusName = '添加评论'
      break
    case 7:
      statusName = '已转交'
      break
    default:
      statusName = '待处理'
      break
    }
    return statusName
})
Vue.filter('materialStepStatusName', function(value) {
  let statusName = ''
  switch (value) {
    case -1:
      statusName = '维保任务发起'
      break
    case 0:
      statusName = '处理中'
      break
    case 1:
      statusName = '已完成'
      break
    case 2:
      statusName = '待处理'
      break
    case 3:
      statusName = '已结束'
      break
    case 4:
      statusName = '已撤销'
      break
    case 5:
      statusName = '已拒绝'
      break
    case 6:
      statusName = '添加评论'
      break
    case 7:
      statusName = '已转交'
      break
    default:
      statusName = '待处理'
      break
    }
    return statusName
})
Vue.filter('feedbackProblemType', function(value) {
  let statusName = ''
  switch (value) {
    case 1:
      statusName = '软件问题'
      break
    case 2:
      statusName = '仪器问题'
      break
    case 3:
      statusName = '试剂问题'
      break
    case 4:
      statusName = '收发货问题'
      break
    case 5:
      statusName = '工程师服务问题'
      break
    case 6:
      statusName = '商务服务问题'
      break
    default:
      statusName = '商务服务问题'
      break
    }
    return statusName
})

Vue.filter('maintenanceStatusClassName', function(value) {
  let statusName = ''
  switch (value) {
    case '待保养':
      statusName = 'red'
      break
    case '待校准':
      statusName = 'red'
      break
    case '保养中':
      statusName = 'green'
      break
    case '校准中':
      statusName = 'green'
      break
    case '维修中':
      statusName = 'grey'
      break
    case '待评分':
      statusName = 'blue'
      break
    default:
      statusName = 'red'
      break
    }
    return statusName
})